package jp.idahopotato.adapter;

import java.util.List;

import jp.idahopotato.bean.Skill;
import jp.matome.activity.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;

/**
 * スキル条件のリスト表示用アダプター
 * @author hiroki
 *
 */
public class SkillSetAdapter extends ArrayAdapter<Skill> {
	private LayoutInflater mInflater;
	private TextView skillName;
	private TextView point;
	private TextView detail;
	private Button deleteButton;

	public SkillSetAdapter(Context context, List<Skill> objects) {
		super(context, 0, objects);
		// TODO 自動生成されたコンストラクター・スタブ
		mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public View getView(int position, View convertView, final ViewGroup parent) {
		// TODO 自動生成されたメソッド・スタブ
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.skillselecteditem, null);
		}
		final Skill item = this.getItem(position);
		if(item != null){
			skillName = (TextView)convertView.findViewById(R.id.nameText);
			skillName.setText(item.getOnSkillName());
			point = (TextView)convertView.findViewById(R.id.point);
			point.setText(item.getPoint());
			detail = (TextView)convertView.findViewById(R.id.detail);
			detail.setText(item.getDetail());
			deleteButton = (Button)convertView.findViewById(R.id.deleteButton);
			deleteButton.setOnClickListener(new OnClickListener() {
				public void onClick(View v) {
					SkillSetAdapter.this.remove(item);
				}
			});
		}
		return convertView;
	}


}
